package com.team11.server.util;

import org.springframework.context.annotation.Configuration;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;

import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Configuration
public class Result {
    public static Map<String,String> notNull( BindingResult result) throws Exception {
        Map<String, String> err = new HashMap();
        List<FieldError> list = result.getFieldErrors();
        FieldError error = null;
        for (int i = 0; i < list.size(); i++) {
            error = list.get(i);
            err.put(error.getField(), error.getDefaultMessage());
        }
        return err;
    }
}
